<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>11_自定义指令的controller</title>
    <script src="./lib/angularjs.js"></script>
</head>

<body ng-app="myApp" ng-controller="myCtrl">
    <controller:of:directive></controller:of:directive>
</body>
<script>
    const myApp = angular.module("myApp", [])
    myApp.controller("myCtrl", ["$scope", function ($scope) {
    }])
    myApp.directive("controllerOfDirective", [function () {
        return {
            restrict: "E",
            replace: true,
            template: `<table border="2px" width="800px">
                <tr>
                    <td>动画名</td>
                    <td>动画时间</td>
                </tr>
                <tr ng-repeat="(k, v) in data">
                    <td>{{v.name}}</td>
                    <td>{{v.time}}</td>
                </tr>
            </table>`,
            controller: ["$scope", function ($scope) {
                $scope.data = [{ name: "龙珠", time: 9 }, { name: "火影忍者", time: 7 }]
            }]
        }
    }])
</script>

</html>